package com.mud.mudcommune.view.fragment.threeLevel;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.facebook.drawee.view.SimpleDraweeView;
import com.mud.mudcommune.R;
import com.mud.mudcommune.adapter.ChiefPagerAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by zhoujin on 2016/12/12.
 */

public class ChiefDetailsFragment extends Fragment implements View.OnClickListener {
    private static Fragment chiefDetailsFragment = new ChiefDetailsFragment();
    @BindView(R.id.head_title)
    TextView title;
    @BindView(R.id.case_back)
    ImageView backImg;
    @BindView(R.id.details_headPic)
    SimpleDraweeView headPic;
    @BindView(R.id.chief_name)
    TextView name;
    @BindView(R.id.chief_level)
    TextView level;
    @BindView(R.id.chief_phone)
    TextView phone;
    @BindView(R.id.chief_tab)
    TabLayout mTabLayout;
    @BindView(R.id.chief_pager)
    ViewPager mViewPager;
    private PagerAdapter pagerAdapter;
    private String[] tabs = {"个人介绍", "设计作品", "评价"};
    Unbinder unbinder;

    public static Fragment getInstance() {
        return chiefDetailsFragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_chief_details, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        title.setText("工长详情");
        name.setText("黄滔");
        level.setText("资深作家");
        phone.setText("1511111111");
        backImg.setOnClickListener(this);
        pagerAdapter = new ChiefPagerAdapter(getChildFragmentManager(), tabs);
        mViewPager.setAdapter(pagerAdapter);
        mTabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.case_back:
                Toast.makeText(getActivity(), "工长详情", Toast.LENGTH_SHORT).show();
                getFragmentManager().popBackStack();
                break;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }
}
